package net.domor.mybatis.demo;

import java.util.List;

import net.domor.mybatis.demo.dao.UserDao;
import net.domor.mybatis.demo.entity.User;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Hello world!
 *
 */
public class App 
{
    @SuppressWarnings("resource")
	public static void main( String[] args )
    {
    	ApplicationContext context = new ClassPathXmlApplicationContext("spring-context.xml");
    	UserDao userDao = context.getBean(UserDao.class);
    	long start = System.currentTimeMillis();
    	List<User> users = userDao.query();
    	long end = System.currentTimeMillis();
    	System.out.println("========== 第一次查询耗时：" + (end - start));
    	for (User user : users) {
    		System.out.println(user.toString());
    	}
    	
    	
    	start = System.currentTimeMillis();
    	users = userDao.query();
    	end = System.currentTimeMillis();
    	System.out.println("========== 第二次查询耗时：" + (end - start));
    	for (User user : users) {
    		System.out.println(user.toString());
    	}
    	
    	
    	start = System.currentTimeMillis();
    	users = userDao.query();
    	end = System.currentTimeMillis();
    	System.out.println("========== 第三次查询耗时：" + (end - start));
    	for (User user : users) {
    		System.out.println(user.toString());
    	}
    	
    }
}
